package com.syq;

/**
 * Created with Intellij IDEA.
 * Description
 * User: wen
 * Date:2022-05-09
 * TIME:20:35
 */
public class Person {
    private String name;
    private int age;
    public void setName(String name){
        this.name = name;
    }
    //
    //setter，设置数据，并且有效的保护我们的成员变量不被胡乱赋值。
    public void setAge(int age){
        if(age < 0){
            this.age = 0;
        }else{
            this.age = age;
        }
    }

    //getter，从成员变量中获取数据
    public String getName(){
        return this.name;
    }
    public int getAge(){
        return this.age;
    }
    public void chi(){
        System.out.println(this.name+"在吃东西");

    }
}
